
int  cpe_refresh_igd_wd_wanetherinterfaceconfig(cwmp_t * cwmp, parameter_node_t * param_node, callback_register_func_t callback_reg)
{
    FUNCTION_TRACE();

    if(!param_node)
    {
        return FAULT_CODE_9002;
    }
    parameter_node_t * tmp_param, *tmp_node, *child_param;
    child_param = param_node->child;
    if(child_param)
    {
        for(tmp_param=child_param->next_sibling; tmp_param; )
        {
            cwmp_log_info("refresh WANConnectionDevice node, delete param %s\n", tmp_param->name);
            tmp_node = tmp_param->next_sibling;
            cwmp_model_delete_parameter(tmp_param);
            tmp_param = tmp_node;
        }
        child_param->next_sibling = NULL;

		cwmp_log_info("ready to get wan index");
        int wan_index = get_index_after_paramname(param_node, "WANDevice"); 

        cwmp_log_info("wan index is:%d", wan_index);
		
        parameter_node_t * wan1conn_param;
        cwmp_model_copy_parameter(param_node, &wan1conn_param, 1);
		
        if(wan_index == 2)
        {
             parameter_node_t * wan2conn_param;
             cwmp_model_copy_parameter(param_node, &wan2conn_param, 2);
        }

        cwmp_model_refresh_object(cwmp, param_node, 0, callback_reg); 
    }

    return FAULT_CODE_OK;
}

#include "netotherapi.h"

int cpe_get_bytes_sent(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)
{
	FUNCTION_TRACE();
    unsigned long long data_send_total = 0;
	char wan_name[30] = {0};
	char tmp[65] = {0};

	cfg_get_item("default_wan_rel", wan_name, sizeof(wan_name));
	getIfStatistic(wan_name, TXBYTE, &data_send_total);
	sprintf(tmp,"%llu",data_send_total);
	*value = pool_pstrdup(pool, tmp);
    return	FAULT_CODE_OK;
}

int cpe_get_bytes_received(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)
{
	FUNCTION_TRACE();
	unsigned long long data_rcv_total = 0;
	char wan_name[30] = {0};
	char tmp[65] = {0};

	cfg_get_item("default_wan_rel", wan_name, sizeof(wan_name));
   	getIfStatistic(wan_name, RXBYTE, &data_rcv_total); //¶ÁÈ¡½ÓÊÕÊý¾Ý;
	sprintf(tmp,"%llu",data_rcv_total);
	*value = pool_pstrdup(pool, tmp);
    return	FAULT_CODE_OK;
}

int cpe_get_packets_sent(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)
{
	FUNCTION_TRACE();
    unsigned long long data_send_total = 0;
	char wan_name[30] = {0};
	char tmp[65] = {0};

	cfg_get_item("default_wan_rel", wan_name, sizeof(wan_name));
	getIfStatistic(wan_name, TXPACKET, &data_send_total);

	sprintf(tmp,"%llu",data_send_total);
	*value = pool_pstrdup(pool, tmp);

    return	FAULT_CODE_OK;
}

int cpe_get_packets_received(cwmp_t * cwmp, const char * name, char ** value, pool_t * pool)
{
	FUNCTION_TRACE();
    unsigned long long data_rcv_total = 0;
	char wan_name[30] = {0};
	char tmp[65] = {0};

	cfg_get_item("default_wan_rel", wan_name, sizeof(wan_name));
   	getIfStatistic(wan_name, RXPACKET, &data_rcv_total); //¶ÁÈ¡½ÓÊÕÊý¾Ý;
	
	sprintf(tmp,"%llu",data_rcv_total);
	*value = pool_pstrdup(pool, tmp);
    return	FAULT_CODE_OK;
}

